#include "searcher.hpp"
#include <stdio.h>
#include <cstring>
#include <iostream>
#include <string>

const std::string input = "data/raw_html/raw.txt";

// 用于本地测试
int main()
{
    // 获取一个Searcher类对象, 并初始化
    ns_searcher::Searcher *search = new ns_searcher::Searcher();
    search->InitSearcher(input);
    
    std::string query;
    std::string json_string;
    char buffer[1024];
    // 根据输入的搜索内容, 调用Search函数, 获得输出参数json_string, 并直接输出测试
    while(true)
    {
        std::cout << "Please Enter Your Search Query# ";
        fgets(buffer, sizeof(buffer) - 1, stdin);
        buffer[strlen(buffer) - 1] = 0;
        query = buffer;
        search->Search(query, &json_string);
        std::cout << json_string << std::endl;
    }

    return 0;
}